/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cpimex.eprice.action;

import com.cpimex.eprice.forms.GerenteRegionalAusenteForm;
import com.cpimex.eprice.model.GerenteRegional;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

/**
 * Level 5 la clase completa es nueva
 */
public class GerenteRegionalAusenteAction extends DispatchAction {
    
     public ActionForward listarGerentesRegionales( ActionMapping mapping, 
             ActionForm form, HttpServletRequest request,
             HttpServletResponse response )throws Exception {

         GerenteRegionalAusenteForm formAction=(GerenteRegionalAusenteForm)form;
         
         ArrayList arrayActivos = GerenteRegional.getGerentesRegionales(0);
         ArrayList arrayAusentes = GerenteRegional.getGerentesRegionales(1);
         
         formAction.setListaGerentes(arrayActivos); 
         formAction.setListaAusentes(arrayAusentes); 
         
         
         return mapping.findForward("listadoGerentes");
     }
     
     public ActionForward ausentes( ActionMapping mapping, 
             ActionForm form, HttpServletRequest request,
             HttpServletResponse response )throws Exception {

         GerenteRegionalAusenteForm formAction=(GerenteRegionalAusenteForm)form;         
         GerenteRegional.cambiarStatusGerentes(formAction.getAusentes(),0);         
         GerenteRegional.cambiarStatusGerentes(formAction.getActivos(),1);         
         
         formAction.reset(mapping, request);
         return mapping.findForward("refrescar");
     }   
     
     public ActionForward cancel( ActionMapping mapping, 
             ActionForm form, HttpServletRequest request,
             HttpServletResponse response )throws Exception {

         GerenteRegionalAusenteForm formAction=(GerenteRegionalAusenteForm)form;

         return mapping.findForward("siguiente");
     }       
    
}
